package com.ruyuan.scholartrade.controller;

import com.scholar.shop.common.CommonRes;
import com.scholar.shop.trad.promotionGoods.api.PromotionGoodsAPI;
import com.scholar.shop.trad.promotionGoods.domain.PromotionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 促销商品客户端实现
 *
 * @author zh
 * @version v7.0
 * @date 19/3/28 上午11:30
 * @since v7.0
 */
@CrossOrigin
@RestController
@RequestMapping("/trade/promotionGoods/open/api")
public class PromotionGoodsAPIController {
    @Autowired
  private PromotionGoodsAPI promotionGoodsAPI ;


    
    @DeleteMapping("/delPromotionGoods/{goodsId}/{type}/{activityId}")
    public CommonRes<Boolean> delPromotionGoods(@PathVariable Integer goodsId, @PathVariable String type, @PathVariable Integer activityId) {
       return this.promotionGoodsAPI.delPromotionGoods(goodsId, type, activityId);

    }


    
    @DeleteMapping("/delPromotionGoods")
    public CommonRes<Boolean> delPromotionGoods(@RequestParam(name = "ids") List<Integer> delSkuIds) {
        //如果delSkuIds为空，则不删除
       return this.delPromotionGoods(delSkuIds) ;

    }

    @GetMapping("/{goodsId}")
    public CommonRes<List<PromotionVO>> getPromotion(Integer goodsId) {
        return this.promotionGoodsAPI.getPromotion(goodsId) ;
    }
}
